﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.访问者模式
{
    public class Computer : IComputerPart
    {
        IComputerPart[] parts;

        public Computer()
        {
            parts = new IComputerPart[]
            {
                new Mouse(),
                new Keyboard(),
                new Monitor()
            };
        }

        public void Accept(IComputerPartVisitor computerPartVisitor)
        {
            foreach(IComputerPart part in parts)
            {
                part.Accept(computerPartVisitor);
            }
            computerPartVisitor.Visit(this);
        }
     }
}
